package com.itheima.test.UDP.IP;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class test {//使用InetAddress类

    public static void main(String[] args) throws UnknownHostException {
        //获得当前主机对象
        InetAddress address = InetAddress.getByName("XB-20201112GEUG");
        //打印主机IP
        System.out.println(address.getHostAddress());//192.168.233.1
        //打印主机名
        System.out.println(address.getHostName());//XB-20201112GEUG
    }
}
